package com.cn.wanxi.service;

import com.cn.wanxi.dao.NewsDao;
import com.cn.wanxi.model.NewsModel;

/**
 * 新闻的服务逻辑层
 */
public class NewsService {

    /**
     * @return
     */
    public NewsModel[] getNewsModelsForHomePage() {
        NewsModel[] newsModels = new NewsModel[3];
        NewsDao newsDao = new NewsDao();

        for (int i = 0; i < newsModels.length; i++) {
            NewsModel newsModel = new NewsModel();
            newsModel.setTitle(newsDao.titlesForHomePage[i]);
            newsModel.setContent(newsDao.contentsForHomePage[i]);
            newsModels[i]=newsModel;
        }
        return newsModels;
    }

    /**
     * @return
     */
    public NewsModel[] getNewsModelsForNewsPage() {
        NewsModel[] newsModels = new NewsModel[10];
        NewsDao newsDao = new NewsDao();
        for (int i = 0; i < newsModels.length; i++) {
            NewsModel newsModel = new NewsModel();
            newsModel.setTitle(newsDao.titlesForNewsPage[i]);
            newsModel.setContent(newsDao.contentsForNewsPage[i]);
            newsModel.setImgHref(newsDao.imgHrefsForNewsPage[i]);
            newsModel.setCreateTime(newsDao.createTimeForNewsPage[i]);
            newsModels[i]=newsModel;
        }
        return newsModels;
    }


}
